CC=gcc
CINCFLAGS=
ifdef TRACE	# Trace socket transfer on stdout
	CTRACEFLAGS=-DTRACE
else
	CTRACEFLAGS=
endif
ifdef PROFILE
	CPROFFLAGS=-p -pg
else
	CPROFFLAGS=
endif
ifdef RELEASE
	COPTFLAGS=-O3 -s 
else
	COPTFLAGS=-O0 -ggdb3 -Werror -Wall
endif
CFLAGS=$(CINCFLAGS) $(COPTFLAGS) $(CPROFFLAGS) $(CTRACEFLAGS) `pkg-config fuse --cflags` -pthread
LFLAGS=-lz `pkg-config fuse --libs` 

BIN=.
PROJECT=9gigafs

all:$(BIN)/$(PROJECT)

$(BIN)/$(PROJECT):$(PROJECT).c $(BIN)/webrequest.o $(BIN)/protocol.o $(BIN)/pathutils.o $(BIN)/filecaching.o
	@echo --------------- Linking of executable ---------------
	@$(CC) $(CFLAGS) -o $(BIN)/$(PROJECT) $^ $(LFLAGS)

$(BIN)/protocol.o:webrequest.h

$(BIN)/pathutils.o:filecaching.h

$(BIN)/%.o:%.c %.h
	@echo --------------- Compilation of $< ---------------
	@$(CC) $(CFLAGS) -c -o $(BIN)/$@ $<

clean:
	@rm *.o
	@rm sandbox

doc:
	@doxygen doxyconf

archive:
	@tar -cvjf $(PROJECT).tar.bz2 *.c *.h Makefile
